[C#] LINQ Group By


In some scenarios, we would like to select each first one row
of the group which we group by personId.

The following code block is a simple example.

var memberList =
    memberSourceData.GroupBy(item => item.personId)
        .Select(chunck => chunck
            .OrderByDescending(c => c.Id)
            .First())
        .ToList();
#C#






你可能感興趣的文章

[TensorFlow Certification Day9] Time Series 初見面 Week1 (4hrs)

[TensorFlow Certification Day9] Time Series 初見面 Week1 (4hrs)

React 的 controller component 與 uncontrolled

React 的 controller component 與 uncontrolled

Day06 : Component 的三種長相

Day06 : Component 的三種長相






留言討論